Skip to content

fix(chat): prevent pushing duplicate badges#178

Merged
olivermrose merged 2 commits intomainfrom
fix/badges
Jan 25, 2026
Merged

fix(chat): prevent pushing duplicate badges#178
olivermrose merged 2 commits intomainfrom
fix/badges

Conversation

@olivermrose
Copy link
Collaborator

Fixes #177

Copilot AI review requested due to automatic review settings January 25, 2026 00:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to prevent external provider badges (BTTV, FFZ, 7TV) from being added multiple times for the same user, fixing the duplicated badge display reported in issue #177.

Changes:

  • Refactors BTTV and FFZ badge assignment in BadgeManager to route through a new #insert helper intended to de-duplicate per-user badges.
  • Updates the 7TV entitlement.create handler to only push a badge to app.badges.users if it is not already present for that user.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/lib/managers/badge-manager.ts Introduces a private #insert helper and uses it when assigning BTTV/FFZ badges to users to avoid duplicates (though the current comparison logic is incorrect).
src/lib/handlers/seventv/entitlement-create.ts Adds per-user badge de-duplication when handling 7TV badge entitlements to avoid pushing the same badge multiple times.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +18 to +22
const badges = getOrInsert(app.badges.users, user.id, []);

if (!badges.some((b) => b.id === badge.id)) {
badges.push(badge);
}
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This handler is re-implementing badge de-duplication logic inline (some/push on app.badges.users), which duplicates similar logic now encapsulated in BadgeManager.#insert. Consider exposing a shared helper on BadgeManager (or another common utility) and invoking it here to keep badge insertion semantics consistent and reduce the risk of future divergence.

Copilot uses AI. Check for mistakes.
@olivermrose olivermrose merged commit 606e47e into main Jan 25, 2026
2 checks passed
@olivermrose olivermrose deleted the fix/badges branch January 25, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provider badges sometime show multiple times

2 participants